package com.zw.mizhe.presenter;

import com.cpoopc.retrofitrxcache.RxCacheResult;
import com.zw.mizhe.api.BaseSubscriber;
import com.zw.mizhe.api.ExceptionHandle;
import com.zw.mizhe.bean.base.BaseDataEntity;
import com.zw.mizhe.common.base.mvp.BasePresenter;
import com.zw.mizhe.model.ISplashModel;
import com.zw.mizhe.model.impl.SplashModelImpl;
import com.zw.mizhe.view.impl.SplashView;

import rx.Subscription;


public class SplashPresenter extends BasePresenter<SplashView> {
    private ISplashModel model;

    public SplashPresenter() {
        model = new SplashModelImpl();
    }

    @Override
    public void addSubscription(Subscription subscriber) {
        super.addSubscription(subscriber);
    }

    public void loadBaseData() {
        model.loadBaseData(new BaseSubscriber<RxCacheResult<BaseDataEntity>>() {

            @Override
            public void onError(ExceptionHandle.ResponeThrowable e) {
                getView().onFail(e);
            }

            @Override
            public void onSuccess(RxCacheResult<BaseDataEntity> result) {
                BaseDataEntity entity = result.getResultModel();
                getView().onSuccess(entity);
            }

            @Override
            public void onFinish() {
                getView().onFinish();
            }
        });
    }

}
